<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class data extends My_Controller {

	function __construct(){
		parent::__construct();
	}
	
	

	//按钮权限检测，给页面提供返回值
	public function button_check(){
		$res=$this->input->post('jsonData');
		//$res='{"directory": "store", "controller": "employee", "func": "department_del"}';
		$obj=json_decode($res,true);
		

		//目录
		$directory = $obj['directory'];
		//控制器
		$controller = $obj['controller'];
		//方法
		$function = $obj['func'];

	//UURI(MD5)
		$this->uuri = md5($directory.$controller.$function);
		if( $directory!="" ){//当非主目录
			if($this->config->item('rbac_auth_on')){//开启认证
				if(!in_array($directory,$this->config->item('rbac_notauth_dirc'))){//需要验证的目录
					
					if($this->config->item('rbac_auth_type')==2){//若为实时认证
						$this->load->model("rbac_model");
						//检测用户状态
						$STATUS = $this->rbac_model->check_user_by_id(rbac_conf(array('INFO','id')));
						if($STATUS==FALSE){
							echo '验证错误2';
							error_redirct($this->config->item('rbac_auth_gateway'),$STATUS);
						}
						//ACL重新赋权
						$this->rbac_model->get_acl(rbac_conf(array('INFO','role_id')));
					}
					
					//验证ACL权限
					if(!rbac_conf(array('ACL',$directory,$controller,$function))){
						echo '{"title":"无权限访问此节点","status":false,"func":"'.$function.'"}';
						
					}else{
						echo '{"title":"有权限访问此节点","status":true,"func":"'.$function.'"}';
					}
				}
			}
		}	
	}	






}